project(sim_jni)
cmake_minimum_required(VERSION 3.1.3)
#使能c++11
set(CMAKE_CXX_STANDARD 11)

#设置生成的so动态库最后输出的路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs_export/${ANDROID_ABI})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs_export/${ANDROID_ABI})

LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})

#设置工程源码根目录
set(JNI_Root ${CMAKE_CURRENT_SOURCE_DIR})

#设置头文件目录
INCLUDE_DIRECTORIES("E:\\android-dev-tools\\android-ndk-r16-beta1\\sysroot\\usr\\include")
INCLUDE_DIRECTORIES(${JNI_Root})

#收集源代码
file(GLOB JNI_src_list ${JNI_Root}/*.cpp ${JNI_Root}/*.c ${JNI_Root}/*.h)

add_definitions(-DDISABLE_MAIN)
if (ANDROID)
    #添加库
    add_library(sim_jni SHARED ${JNI_src_list})
    add_definitions(-DANDROID)

    #链接
    target_link_libraries(sim_jni log z)
else ()
    add_executable(sim ${JNI_src_list})
    #链接
    target_link_libraries(sim pthread)
endif ()

